<?php

namespace App\Admin\Controllers;

use App\Http\Controllers\Controller;
use LowCode\Block;
use LowCode\Core\Admin;
use LowCode\Core\Response;
use LowCode\Naive;
use LowCode\Page;
use LowCode\UI;

class LoginController extends Controller
{
    public function index()
    {
        $page = Page::make(Block::make("LoginController",function (Block $block){
            if (Admin::isInstall()){
                $route = request()->route();
                $name = $route->parameter("module");
                $block->css(".login-module{width:100%;padding:0 50px;margin-top:120px}");
                $block->nodes([
                    UI::node($name)->class("login-module")
                ]);
            }else{
                $block->state("current",1);
                $steps = Naive::steps([
                    Naive::step('系统检测'),
                    Naive::step("数据库检测"),
                    Naive::step("安装数据库"),
                    Naive::step("安装完成"),
                ]);
                $steps->vertical()->vModelCurrent("state.current");
                $card = Naive::card("安装后台",$steps)->bordered(false);
                $block->nodes([
                    $card
                ]);
            }
        }));
        return response()->json(Response::success("ok",$page));
    }
}
